//
// Created by root on 6/22/17.
//

#ifndef FUNNY_FILEBUFFER_H
#define FUNNY_FILEBUFFER_H

#include <gtk/gtk.h>
#include "gdkkeysyms.h"  /* for GDK key values */

#include "editor.h"
#include "dialog.h"
#include "statusbar.h"

/* TODO:
 *  implement buffer_chk_mod in windef.c on changed signal, needs work.
 *  check implementing app->status to remove gtk_statusbar.h dependency.
 */

// gboolean buffer_chk_mod (FunnyWindow *app);
#ifdef HAVESOURCEVIEW
#include <gtksourceview/gtksourcestyleschememanager.h>
void sourceview_guess_language (FunnyWindow *app);
void sourceview_get_languange_info (FunnyWindow *app);
void sourceview_get_scheme_info (FunnyWindow *app);
#endif
void buffer_clear (FunnyWindow *app);
void buffer_insert_file (FunnyWindow *app, gchar *filename);
gboolean buffer_select_all (FunnyWindow *app);
gboolean buffer_deselect_all (FunnyWindow *app);
void buffer_comment_lines (FunnyWindow *app, GtkTextIter *start, GtkTextIter *end);
void buffer_uncomment_lines (FunnyWindow *app, GtkTextIter *start, GtkTextIter *end);
gboolean buffer_check_save_on_exit (GtkTextBuffer *buffer);
void buffer_handle_quit (FunnyWindow *app);
void buffer_save_file (FunnyWindow *app, gchar *filename);
void buffer_write_file (FunnyWindow *app, gchar *filename);

void gtkwrite_window_set_title (GtkWidget *widget, FunnyWindow *app);
void split_fname (FunnyWindow *app);

void buffer_indent_lines (FunnyWindow *app, GtkTextIter *start, GtkTextIter *end);
void buffer_unindent_lines (FunnyWindow *app, GtkTextIter *start, GtkTextIter *end);
void buffer_indent_lines_fixed (FunnyWindow *app, GtkTextIter *start, GtkTextIter *end);
void buffer_unindent_lines_fixed (FunnyWindow *app, GtkTextIter *start, GtkTextIter *end);
gboolean buffer_indent_auto (FunnyWindow *app);
gboolean smart_backspace (FunnyWindow *app);
gboolean smart_tab (FunnyWindow *app);
gboolean smart_home (FunnyWindow *app);
void buffer_remove_trailing_ws (GtkTextBuffer *buffer);
void buffer_require_posix_eof (GtkTextBuffer *buffer);
void buffer_content_stats (GtkTextBuffer *buffer);

gsize g_strlen (const gchar *s);
gboolean str2lower (gchar *str);
gboolean str2upper (gchar *str);
gboolean str2title (gchar *str);
gboolean joinlines (gchar *s);
void selection_for_each_char (GtkTextBuffer *buffer, gboolean (*fn) (gchar *));

/* temp dump functions */
gboolean dump2lower (gchar *str);
void selection_dump (GtkTextBuffer *buffer, gboolean (*fn) (gchar *));

#endif //FUNNY_FILEBUFFER_H
